package com.sky.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Employee implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private String username;

    private String name;

    private String password;

    private String phone;

    private String sex;

    private String idNumber;

    private Integer status;

    //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    private Long createUser;

    private Long updateUser;
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

        Employee employee = new Employee();
        Method[] declaredMethods = employee.getClass().getDeclaredMethods();
        for (Method method : declaredMethods){
            System.out.println(method.getName());
        }

        Method setCreateTime = employee.getClass().getDeclaredMethod("setCreateTime",LocalDateTime.class);
        LocalDateTime now = LocalDateTime.now();
        setCreateTime.invoke(employee,now);
        System.out.println(employee);

        Method getCreateTime = employee.getClass()
                .getDeclaredMethod("getCreateTime");
        Object result = getCreateTime.invoke(employee,null);
        System.out.println(result);
    }


}
